package org.feng.fxfront.util;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 时间工具类
 *
 * @version v1.0
 * @author: fengjinsong
 * @date: 2024年01月18日 22时40分
 */
public class TimeUtil {
    private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

    public static String parse(LocalDateTime localDateTime) {
        if (localDateTime == null) {
            return "";
        }
        return DATE_TIME_FORMATTER.format(localDateTime);
    }


    public static LocalDateTime format(String dateTime) {
        if (dateTime == null) {
            return null;
        }
        return LocalDateTime.parse(dateTime, DATE_TIME_FORMATTER);
    }
}
